package com.jrx.anytxn.param.job.cutover.step;

import com.jrx.anytxn.param.entity.PrOrganizationTable;
import com.jrx.anytxn.param.mapper.ext.ExtPrOrganizationTableMapper;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
/**
 * 日切任务  - writer
 * @author Qingyao Xing
 * @date 2019/9/9 13:30
 */
@Service
public class CutoverWriter implements ItemWriter<PrOrganizationTable> {

    @Autowired
    private ExtPrOrganizationTableMapper extPrOrganizationTableMapper;
    @Override
    public void write(List items) {
        List<PrOrganizationTable> list =new ArrayList<>();
        for (Object item : items) {
            PrOrganizationTable organizationTable = (PrOrganizationTable) item;
            if(null!=organizationTable){
                list.add(organizationTable);
            }
        }
        for (PrOrganizationTable organizationTable:list ) {
            extPrOrganizationTableMapper.updateDayCut(organizationTable);
        }

    }
}
